using System.Collections.Generic;
using System.Configuration;
using System.Xml;

namespace LaBruteTrainer.Configuration
{
    public class BruteConfigurationSessionHandler : IConfigurationSectionHandler
    {
        #region IConfigurationSectionHandler Members

        public object Create(object parent, object configContext, XmlNode section)
        {
            var configuration = new BruteConfiguration {myBrutes = new List<BruteCfg>()};

            foreach (XmlNode childNode in section.ChildNodes)
            {
                if (childNode.Name == "Brute")
                    configuration.myBrutes.Add(new BruteCfg
                                                   {
                                                       Name = childNode.Attributes["Name"].Value,
                                                       Password = childNode.Attributes["Password"].Value
                                                   });
            }
            return configuration;
        }

        #endregion
    }
}